<?php
require_once("inc/global_funcs.inc.php");
require_once("inc/login_header.inc.php");
require_once("inc/login.inc.php");

if(isset($_POST['submit']))
{
    $login_obj = new login($_POST);
    $login_res = $login_obj->authenticate();
    
    if($login_res == true)
    {
        if($_POST['ref'] != "")
            header("location: ".$_SERVER['HTTP_REFERER']);
        else
            header("location: index.php");
    }
}


?>
<html>
<head>
<title>Login</title>
</head>
<body>
<form method="POST" action="">
<fieldset>
<legend>Login</legend>
<table>
    <tr>
        <td>Username</td><td><input type='text' name='uname'></td>
    </tr>
    <tr>
        <td>Password</td><td><input type='password' name='passwd'></td>
    </tr>
    <tr colspan='2'>
        <td><input type='hidden' name='ref' value='<?php echo $_SERVER['HTTP_REFERER'] ?>'>
        <input type='submit' name='submit' value ='Submit'></td>
    </tr>
</table>
</fieldset>
</body>
</html>
